package com.example.demo.controller;

import com.example.demo.Mappers.PacsInfoMapper;
import com.example.demo.beans.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Administrator on 2018-10-20.
 */
@RestController
public class GetPacsInfoController {
@Autowired
    private PacsInfoMapper mapper;
@ResponseBody
    @RequestMapping(value = "GetPacsPatientInfo",produces ="application/xml" )
    public GetPacsInfoResponse GetPacsPatientInfo(@RequestBody GetPacsInfoRequest request)
{
    GetPacsInfoResponse response=new GetPacsInfoResponse();
    if(request.getCardNo()!=null&&!request.getCardNo().equals(""))
{
    List<PacsTempBean> tempBeans=mapper.getTempPacsInfo(request.getCardNo(),request.getStartDate(),request.getEndDate());
    if(tempBeans==null)
    {response.setResultCode("1");
    response.setResultMsg("该卡号对应的信息在该时间段内没有查询到，如有问题请与医院联系核实！对您带来的不变敬请谅解");
    return response;
    }
    else {
        response.setResultCode("0");
        response.setResultMsg("查询成功");
        response.setItems(tempBeans);
        return  response;
    }


}
    response.setResultCode("1");
    response.setResultMsg("您传入的参数有误，请核实");
    return response;

}


    @RequestMapping(value = "GetPacsInfo",produces ="application/xml" )
    public GetPacsInfosResponse GetPacsInfo(@RequestBody GetLisInfoRequest request)
    {
        GetPacsInfosResponse response=new GetPacsInfosResponse();
        if(request!=null)
        {
            List<GetPacsInfoR> tempBeans=mapper.GetPacsInfo(request.getStartDate(),request.getEndDate());
            if(tempBeans==null)
            {response.setResultCode("1");
                response.setResultMsg("该卡号对应的信息在该时间段内没有查询到，如有问题请与医院联系核实！对您带来的不变敬请谅解");
                return response;
            }
            else {
                response.setResultCode("0");
                response.setResultMsg("查询成功");
                response.setList(tempBeans);
                return  response;
            }


        }
        response.setResultCode("1");
        response.setResultMsg("您传入的参数有误，请核实");
        return response;

    }


@ResponseBody
    @RequestMapping(value = "GetPacsMxInfo",produces = "application/xml")
   public GetPacsMxResponse GetPacsMxInfo(@RequestBody GetPacsMxRequest request)
  { GetPacsMxResponse response=new GetPacsMxResponse();
   if(request.getRepId()!=null&&!request.getRepId().equals(""))
   { GetPacsMxTemBean temBean=mapper.getPacsMxInfo(request.getRepId());
   if(temBean!=null)
   {response.setResultCode("0");
   response.setResultMsg("查询成功");
   response.setBean(temBean);
   return response;

   }
   else {response.setResultCode("1");
   response.setResultMsg("抱歉！根据您传入的参数没有查询到相应的信息，请到相关科室核实，以科室报告为准");
   return  response;
   }
   }
   response.setResultCode("1");
   response.setResultMsg("您传入的参数有误，请核实！");
  return  response;
  }


}
